package puzzle.projecteuler.p100;

public class Problem014 {

	public static void main(String[] args) {
		
		int max = 0;
		int num = 0;
		for (int i = 1; i <= 1000000; i ++) {
			int l = length(i);
			if (max < l) {
				max = l;
				num = i;
			}
		}
		System.out.println(max);
		System.out.println(num);
	}
	
	public static int length(long n) {	/*here, should be 'long', not an 'int'!!!*/
		int c = 1;
		while (n > 1) {
			if (n%2 == 0) {
				n /= 2;
			} else {
				n = 3*n+1;
			}
			c ++;
		}
		return c;
	}
}
